package com.beici.vueblogapp.controller;

import com.beici.vueblogapp.model.blogSite;
import com.beici.vueblogapp.model.results;
import com.beici.vueblogapp.service.siteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
public class siteController {
    @Autowired
    private siteService siteServiceImp;

    @GetMapping("/getSiteAll")
    public results getSiteAll(){

        return  siteServiceImp.getSiteAll();
    }
    @GetMapping("/getThroughSiteAll")
    public results getThroughSiteAll(){

        return  siteServiceImp.getThroughSiteAll();
    }

    @PostMapping("/commitSity")
    public results commitSity( String sityName,
                               String sityUri,
                               String sityEmail,
                               String sityMesasge){

        results result = siteServiceImp.commitSity(new blogSite(sityName, sityUri,sityMesasge,sityEmail));
        return result;
    }

    @PostMapping("/UpdateSityCode")
    public results UpdateSityCode(Integer id,Integer code){
        System.out.println(id);
        System.out.println(code);
       return siteServiceImp.updateSityCode(id,code);
    }

}
